package com.fireline.beauty.member;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ControlEditor;
import org.eclipse.swt.custom.TableCursor;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.wb.swt.SWTResourceManager;

import com.fireline.beauty.jdbc.SqliteJdbcImpl;
import com.zgw.fireline.base.controls.DataCombo;
import com.zgw.fireline.base.controls.DataTable;
import com.zgw.fireline.base.controls.DataTableColumn;
import com.zgw.fireline.base.dataset.Dataset;
import com.zgw.fireline.base.frame.IFunction;
import com.zgw.fireline.base.widgets.Batch;
import com.zgw.fireline.base.widgets.BatchItem;
import com.zgw.fireline.base.widgets.cdatetime.CDT;
import com.zgw.fireline.base.widgets.cdatetime.CDateTime;
import com.zgw.fireline.base.IDataBaseProvide;

/**
 * 会员新增修改
 * */
public class HyglEdit implements IFunction {

	private Text textHybh;
	private Text textHyxm;
	private Combo comboLb;
	private Text textJj;
	private Text textSj;
	private Text textBz;
	private Combo textXb;

	private Text text_2;
	private Text text_3;
	private Text text_4;
	private Text text_5;
	private Text text_6;
	private Text text_7;
	private Text text_8;

	private DataCombo dataCombo_2;
	private Button button_6;

	private int type;
	public int result;
	private CDateTime dateTimeDqsj;
	private Control content;
	/**
	 * @wbp.nonvisual location=17,552
	 */
	private final Dataset hykSet = new Dataset("select * from hykxx",
			SqliteJdbcImpl.INSTANCE);
	/**
	 * @wbp.nonvisual location=67,552
	 */
	private final Dataset ygSet = new Dataset("select * from ygxx",
			SqliteJdbcImpl.INSTANCE);
	private DataCombo dataCombo;
	/**
	 * @wbp.nonvisual location=107,552
	 */
	private final Dataset tcSet = new Dataset("\r\n\tSELECT * FROM TCXX",
			SqliteJdbcImpl.INSTANCE);
	/**
	 * @wbp.nonvisual location=7,602
	 */
	private final Dataset hyxxSet = new Dataset(
			"select *,sr||csrq hysr from hyxx where hybh=?",
			SqliteJdbcImpl.INSTANCE);

	/**
	 * @wbp.nonvisual location=57,602
	 */
	private final Dataset hljhSet = new Dataset(
			"select * from hyhljh where hybh=?", SqliteJdbcImpl.INSTANCE);
	/**
	 * @wbp.nonvisual location=3,652
	 */
	private final Batch hyxxEdit = new Batch(SqliteJdbcImpl.INSTANCE);
	private Combo combo_1;
	private DataTable dataTableHljh;
	/**
	 * @wbp.nonvisual location=107,602
	 */
	private final Dataset hlxmSet = new Dataset("select * from hlxm",
			SqliteJdbcImpl.INSTANCE);
	/**
	 * @wbp.nonvisual location=147,552
	 */
	private final Dataset tcfwxmSet = new Dataset(true, "tcfwxm",
			SqliteJdbcImpl.INSTANCE);
	/**
	 * @wbp.nonvisual location=63,652
	 */
	private final Batch hyxxAdd = new Batch(SqliteJdbcImpl.INSTANCE);
	private Combo combo;
	/**
	 * @wbp.nonvisual location=157,602
	 */
	private final Dataset newId = new Dataset(
			"select max(hybh)+1 newId from hyxx where \r\nlength(hybh)=6",
			SqliteJdbcImpl.INSTANCE);
	public String hybh;

	public HyglEdit(String hybh) {
		this.type = IFunction.Edit;
		hyxxSet.setParam(0, hybh);
		hyxxSet.update();
		hyxxSet.setSelected(0);
	}

	public HyglEdit() {
		this.type = IFunction.Add;
	}

	/**
	 * @wbp.parser.entryPoint
	 */
	public Control createControl(Composite parent) {
		hykSet.setKeyColumns(new String[] { "hykmc" });
		tcSet.setKeyColumns(new String[] {});
		ygSet.setKeyColumns(new String[] { "ygbh" });
		hyxxSet.setKeyColumns(new String[] {});
		hljhSet.setKeyColumns(new String[] {});

		BatchItem batchItem = new BatchItem(hyxxEdit);
		batchItem
				.setCommand("update hyxx set hyxm=?,xb=?,sr=?,csrq=?\r\n,lxdh=?,isqx=?,dqsj=?,mm=?,bz=?,pfzk=?,\r\nhykmc=?,ygbh=?\r\nwhere hybh=?");
		batchItem.setName("修改会员基本信息");

		BatchItem batchItem_1 = new BatchItem(hyxxEdit);
		batchItem_1.setCommand("delete from hyhljh where hybh=?");
		batchItem_1.setName("删除所有护理计划");
		hlxmSet.setKeyColumns(new String[] {});
		tcfwxmSet.setKeyColumns(new String[] {});

		BatchItem batchItem_2 = new BatchItem(hyxxAdd);
		batchItem_2
				.setCommand("insert into hyxx(hybh, hyxm,xb,sr,csrq\r\n,lxdh,isqx,dqsj,mm,bz,pfzk,\r\nhykmc,ygbh) \r\nvalues(?,?,?,?,?,?,?,?,?,?,?,?,?)");
		batchItem_2.setName("新增会员基本信息");

		BatchItem batchItem_3 = new BatchItem(hyxxAdd);
		batchItem_3.setCommand("delete from hyhljh where hybh=?");
		batchItem_3.setName("删除所有护理计划");

		BatchItem batchItem_4 = new BatchItem(hyxxAdd);
		batchItem_4
				.setCommand("\r\ninsert into hytc\r\nSELECT \r\n  ? hybh,\r\n  t1.tcbh,\r\n  t2.xmbh , \r\n  t1.cs , \r\n  t1.cs sycs,\r\n  t1.yhdj,\r\n  t1.zq , \r\n  t1.bz \r\nFROM \r\n  tcfw t1 LEFT JOIN \r\n  fwxm t2 ON t1.xmbh = t2.xmbh where t1.tcbh=?\r\n");
		batchItem_4.setName("添加套餐");
		newId.setKeyColumns(new String[] {});
		Composite content = new Composite(parent, SWT.NONE);
		content.setLayout(new GridLayout(1, false));

		Group composite = new Group(content, SWT.NONE);
		composite.setText("基本信息");
		GridLayout gl_composite = new GridLayout(4, false);
		gl_composite.verticalSpacing = 15;
		gl_composite.horizontalSpacing = 0;
		composite.setLayout(gl_composite);
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
				1, 1));
		{
			Label lblNewLabel = new Label(composite, SWT.NONE);
			lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
					false, false, 1, 1));
			lblNewLabel.setText("会员编号：");
		}
		{
			textHybh = new Text(composite, SWT.BORDER);
			textHybh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
		}
		{
			Label label = new Label(composite, SWT.NONE);
			{
				GridData gd_label = new GridData(SWT.RIGHT, SWT.CENTER, false,
						false, 1, 1);
				gd_label.horizontalIndent = 20;
				label.setLayoutData(gd_label);
			}
			label.setText("会员姓名：");
		}
		{
			textHyxm = new Text(composite, SWT.BORDER);
			textHyxm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
					false, 1, 1));
		}
		{
			Label label = new Label(composite, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("会员性别：");
		}
		{
			textXb = new Combo(composite, SWT.READ_ONLY);
			textXb.setItems(new String[] { "男", "女" });
			textXb.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
			textXb.select(0);
		}
		{
			Label label = new Label(composite, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("会员生日：");
		}
		{
			Composite composite_1 = new Composite(composite, SWT.NONE);
			composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
					false, 1, 1));
			GridLayout gl_composite_1 = new GridLayout(5, false);
			gl_composite_1.horizontalSpacing = 0;
			gl_composite_1.verticalSpacing = 0;
			gl_composite_1.marginWidth = 0;
			gl_composite_1.marginHeight = 0;
			composite_1.setLayout(gl_composite_1);
			{
				comboLb = new Combo(composite_1, SWT.READ_ONLY);
				comboLb.setItems(new String[] { "农历", "公历" });
				comboLb.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
						true, 1, 1));
				comboLb.select(1);
			}
			{
				combo_1 = new Combo(composite_1, SWT.READ_ONLY);
				combo_1.setItems(new String[] { "1", "2", "3", "4", "5", "6",
						"7", "8", "9", "11", "12" });
				GridData gd_combo_1 = new GridData(SWT.FILL, SWT.CENTER, false,
						false, 1, 1);
				gd_combo_1.horizontalIndent = 6;
				combo_1.setLayoutData(gd_combo_1);
				combo_1.select(0);
			}
			{
				Label lblNewLabel_1 = new Label(composite_1, SWT.NONE);
				lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
						false, false, 1, 1));
				lblNewLabel_1.setText("月");
			}
			{
				combo = new Combo(composite_1, SWT.READ_ONLY);
				combo.setVisibleItemCount(31);
				combo.setItems(new String[] { "1", "2", "3", "4", "5", "6",
						"7", "8", "9", "11", "12", "13", "14", "15", "16",
						"17", "18", "19", "20", "21", "22", "23", "24", "25",
						"26", "27", "28", "29", "30", "31" });
				GridData gd_combo = new GridData(SWT.FILL, SWT.CENTER, false,
						false, 1, 1);
				gd_combo.horizontalIndent = 6;
				combo.setLayoutData(gd_combo);
				combo.select(0);
			}
			{
				Label lblNewLabel_1 = new Label(composite_1, SWT.NONE);
				lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
						false, false, 1, 1));
				lblNewLabel_1.setText("日");
			}
		}
		{
			Label label = new Label(composite, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("联系电话：");
		}
		{
			text_2 = new Text(composite, SWT.BORDER);
			text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
		}
		{
			button_6 = new Button(composite, SWT.CHECK);
			button_6.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					dateTimeDqsj.setEnabled(button_6.getSelection());
					if (dateTimeDqsj.getSelection() == null)
						dateTimeDqsj.setSelection(new java.util.Date());
				}
			});
			button_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			button_6.setText("到期日期");
		}

		dateTimeDqsj = new CDateTime(composite, CDT.BORDER | SWT.BORDER
				| CDT.SPINNER);
		dateTimeDqsj.setPattern("yyyy-MM-dd");
		dateTimeDqsj.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
				false, 1, 1));
		{
			Label label = new Label(composite, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("会员密码：");
		}
		{
			textJj = new Text(composite, SWT.BORDER);
			textJj.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
		}
		{
			Label label = new Label(composite, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("确认密码：");
		}
		{
			textSj = new Text(composite, SWT.BORDER);
			textSj.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
					false, 1, 1));
		}
		{
			Label label = new Label(composite, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("备注信息：");
		}
		{
			textBz = new Text(composite, SWT.BORDER);
			textBz.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 3, 1));
		}

		TabFolder tabFolder = new TabFolder(content, SWT.NONE);
		GridData gd_composite_3 = new GridData(SWT.FILL, SWT.CENTER, true,
				false, 1, 1);
		gd_composite_3.heightHint = 200;
		tabFolder.setLayoutData(gd_composite_3);

		TabItem tbtmNewItem = new TabItem(tabFolder, SWT.NONE);
		tbtmNewItem.setText("使用会员卡");
		{
			Composite composite_1 = new Composite(tabFolder, SWT.NONE);
			tbtmNewItem.setControl(composite_1);
			GridLayout gl_composite_1 = new GridLayout(4, false);
			gl_composite_1.marginHeight = 15;
			gl_composite_1.marginWidth = 15;
			gl_composite_1.verticalSpacing = 15;
			gl_composite_1.horizontalSpacing = 0;
			composite_1.setLayout(gl_composite_1);

			Label label = new Label(composite_1, SWT.NONE);
			label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label.setText("会员卡名称：");

			dataCombo_2 = new DataCombo(composite_1, SWT.READ_ONLY, hykSet);
			dataCombo_2.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					text_3.setText(hykSet.getValue("knje", String.class, ""));
					text_4.setText(hykSet.getValue("sj", String.class, ""));
					text_5.setText(hykSet.getValue("fwzk", String.class, ""));
					text_6.setText(hykSet.getValue("cpzk", String.class, ""));
					text_7.setText(hykSet.getValue("bz", String.class, ""));
				}
			});
			dataCombo_2.setShowText("${hykmc}");
			dataCombo_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
					false, 1, 1));

			Label label_1 = new Label(composite_1, SWT.NONE);
			GridData gd_label_1 = new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1);
			gd_label_1.horizontalIndent = 20;
			label_1.setLayoutData(gd_label_1);
			label_1.setText("美容顾问：");

			DataCombo dataCombo_1 = new DataCombo(composite_1, SWT.READ_ONLY,
					ygSet);
			dataCombo_1.setShowText("${ygmc}");
			dataCombo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));

			Label label_2 = new Label(composite_1, SWT.NONE);
			label_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label_2.setText("卡内金额：");

			text_3 = new Text(composite_1, SWT.BORDER);
			text_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));

			Label label_3 = new Label(composite_1, SWT.NONE);
			label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label_3.setText("售价：");

			text_4 = new Text(composite_1, SWT.BORDER);
			text_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));

			Label lblNewLabel_2 = new Label(composite_1, SWT.NONE);
			lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
					false, false, 1, 1));
			lblNewLabel_2.setText("服务折扣：");

			text_5 = new Text(composite_1, SWT.BORDER | SWT.READ_ONLY);
			text_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));

			Label label_4 = new Label(composite_1, SWT.NONE);
			label_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label_4.setText("产品折扣：");

			text_6 = new Text(composite_1, SWT.BORDER | SWT.READ_ONLY);
			text_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));

			Label label_5 = new Label(composite_1, SWT.NONE);
			label_5.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
					false, 1, 1));
			label_5.setText("备注：");

			text_7 = new Text(composite_1, SWT.BORDER | SWT.READ_ONLY);
			text_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 3, 1));

		}

		TabItem tbtmNewItem_1 = new TabItem(tabFolder, SWT.NONE);
		tbtmNewItem_1.setText("使用套餐");
		{
			Composite composite_1 = new Composite(tabFolder, SWT.NONE);
			tbtmNewItem_1.setControl(composite_1);
			GridLayout gl_composite_1 = new GridLayout(4, false);
			gl_composite_1.marginTop = 5;
			composite_1.setLayout(gl_composite_1);
			{
				Label lblNewLabel_3 = new Label(composite_1, SWT.NONE);
				lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
						false, false, 1, 1));
				lblNewLabel_3.setText("使用套餐：");
			}

			dataCombo = new DataCombo(composite_1, SWT.READ_ONLY, tcSet);
			dataCombo.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					setParams();
					tcfwxmSet.update();
				}
			});
			dataCombo.setShowText("${tcmc}");
			dataCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
					false, 1, 1));

			Label lblNewLabel_4 = new Label(composite_1, SWT.NONE);
			lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
					true, false, 1, 1));
			lblNewLabel_4.setText("套餐售价：");

			Label lblNewLabel_5 = new Label(composite_1, SWT.NONE);
			GridData gd_lblNewLabel_5 = new GridData(SWT.LEFT, SWT.CENTER,
					false, false, 1, 1);
			gd_lblNewLabel_5.widthHint = 100;
			gd_lblNewLabel_5.minimumWidth = 100;
			lblNewLabel_5.setLayoutData(gd_lblNewLabel_5);

			DataTable dataTable = new DataTable(composite_1, SWT.BORDER
					| SWT.FULL_SELECTION, tcfwxmSet);
			GridData gd_dataTable = new GridData(SWT.FILL, SWT.FILL, false,
					true, 4, 1);
			gd_dataTable.widthHint = 410;
			dataTable.setLayoutData(gd_dataTable);
			dataTable.setHeaderVisible(true);
			dataTable.setLinesVisible(true);

			DataTableColumn dataTableColumn = new DataTableColumn(dataTable,
					SWT.NONE, "xmbh");
			dataTableColumn.setText("项目编号");
			dataTableColumn.setWidth(63);

			DataTableColumn dataTableColumn_1 = new DataTableColumn(dataTable,
					SWT.NONE, "xmmc");
			dataTableColumn_1.setText("项目名称");
			dataTableColumn_1.setWidth(63);

			DataTableColumn dataTableColumn_2 = new DataTableColumn(dataTable,
					SWT.RIGHT, "dj");
			dataTableColumn_2.setText("原价");
			dataTableColumn_2.setWidth(40);

			DataTableColumn dataTableColumn_3 = new DataTableColumn(dataTable,
					SWT.RIGHT, "cs");
			dataTableColumn_3.setToolTipText("服务次数");
			dataTableColumn_3.setText("次数");
			dataTableColumn_3.setWidth(40);

			DataTableColumn dataTableColumn_4 = new DataTableColumn(dataTable,
					SWT.RIGHT, "yhdj");
			dataTableColumn_4.setText("优惠价");
			dataTableColumn_4.setWidth(52);

			DataTableColumn dataTableColumn_5 = new DataTableColumn(dataTable,
					SWT.RIGHT, "hj");
			dataTableColumn_5.setText("合计");
			dataTableColumn_5.setWidth(40);

			DataTableColumn dataTableColumn_6 = new DataTableColumn(dataTable,
					SWT.NONE, "zq");
			dataTableColumn_6.setText("周期");
			dataTableColumn_6.setWidth(40);

			DataTableColumn dataTableColumn_7 = new DataTableColumn(dataTable,
					SWT.NONE, "bz");
			dataTableColumn_7.setText("备注");
			dataTableColumn_7.setWidth(80);

		}

		{
			TabItem tbtmNewItem_2 = new TabItem(tabFolder, SWT.NONE);
			tbtmNewItem_2.setText("皮肤状况");

			Composite composite_1 = new Composite(tabFolder, SWT.NONE);
			tbtmNewItem_2.setControl(composite_1);
			composite_1.setLayout(new GridLayout(1, false));

			text_8 = new Text(composite_1, SWT.BORDER | SWT.V_SCROLL);
			text_8.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true,
					1, 1));

			Button btnNewButton_2 = new Button(composite_1, SWT.NONE);
			btnNewButton_2.setText("编辑皮肤状况");
		}
		{
			TabItem tbtmNewItem_3 = new TabItem(tabFolder, SWT.NONE);
			tbtmNewItem_3.setText("护理计划");

			Composite composite_1 = new Composite(tabFolder, SWT.NONE);
			tbtmNewItem_3.setControl(composite_1);
			composite_1.setLayout(new GridLayout(1, false));

			dataTableHljh = new DataTable(composite_1, SWT.BORDER
					| SWT.HIDE_SELECTION, hljhSet);
			dataTableHljh.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
					true, 1, 1));
			dataTableHljh.setHeaderVisible(true);
			dataTableHljh.setLinesVisible(true);
			dataTableHljh.addListener(SWT.EraseItem, new Listener() {
				@Override
				public void handleEvent(Event event) {
					if (event.index == 0) {
						Color old = event.gc.getBackground();
						event.gc.setBackground(SWTResourceManager.getColor(255,
								255, 225));
						event.gc.fillRectangle(event.x, event.y, event.width,
								event.height);
						event.gc.setBackground(old);
						event.detail &= ~SWT.SELECTED;
					}
				}
			});
			dataTableHljh.addListener(SWT.MeasureItem, new Listener() {
				@Override
				public void handleEvent(Event event) {
					event.height = 20;
				}
			});
			DataTableColumn dataTableColumn = new DataTableColumn(
					dataTableHljh, SWT.NONE, "hlxmmc");
			dataTableColumn.setText("护理项目名称");
			dataTableColumn.setWidth(120);

			DataTableColumn dataTableColumn_1 = new DataTableColumn(
					dataTableHljh, SWT.NONE, "hlnr");
			dataTableColumn_1.setText("护理内容");
			dataTableColumn_1.setWidth(300);

			final TableCursor tableCursor = new TableCursor(dataTableHljh,
					SWT.NONE);
			final ControlEditor hljhEditor = new ControlEditor(tableCursor);
			hljhEditor.grabHorizontal = true;
			hljhEditor.grabVertical = true;
			final Text editorText = new Text(tableCursor, SWT.BORDER);
			final DataCombo editorCombo = new DataCombo(tableCursor, SWT.NONE,
					hlxmSet);
			editorText.addModifyListener(new ModifyListener() {
				@Override
				public void modifyText(ModifyEvent e) {
					if (tableCursor.getRow() != null)
						tableCursor.getRow().setText(tableCursor.getColumn(),
								editorText.getText());
				}
			});
			editorCombo.addModifyListener(new ModifyListener() {
				@Override
				public void modifyText(ModifyEvent e) {
					if (tableCursor.getRow() != null)
						tableCursor.getRow().setText(tableCursor.getColumn(),
								editorCombo.getText());
				}
			});
			editorCombo.setShowText("${hlxmmc}");
			final SelectionAdapter activeEditor = new SelectionAdapter() {
				public void widgetSelected(SelectionEvent e) {
					TableItem item = tableCursor.getRow();
					dataTableHljh.setSelection(item);
					if (tableCursor.getColumn() == 0) {
						editorText.setVisible(false);
						editorCombo.setVisible(true);
						editorCombo.setText(item.getText(0));
						editorCombo.setSelection(new Point(0, item.getText(0)
								.length()));
						hljhEditor.setEditor(editorCombo);
					} else if (tableCursor.getColumn() == 1) {
						editorCombo.setVisible(false);
						editorText.setVisible(true);
						editorText.setText(item.getText(1));
						editorText.selectAll();
						hljhEditor.setEditor(editorText);
					}
				};
			};
			tableCursor.addSelectionListener(activeEditor);
			ToolBar toolBar = new ToolBar(composite_1, SWT.FLAT | SWT.RIGHT);
			ToolItem tltmNewItem = new ToolItem(toolBar, SWT.NONE);
			tltmNewItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					TableItem item = new TableItem(dataTableHljh, SWT.NONE);
					dataTableHljh.setSelection(item);
					tableCursor.setSelection(item, 0);
					activeEditor.widgetSelected(null);
				}
			});
			tltmNewItem.setSelection(true);
			tltmNewItem.setText("新增");

			ToolItem toolItem = new ToolItem(toolBar, SWT.SEPARATOR);

			ToolItem tltmNewItem_1 = new ToolItem(toolBar, SWT.NONE);
			tltmNewItem_1.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					if (dataTableHljh.getSelectionCount() > 0) {
						dataTableHljh.getSelection()[0].dispose();
					}
				}
			});
			tltmNewItem_1.setText("删除");
		}
		{
			TabItem tbtmNewItem_4 = new TabItem(tabFolder, SWT.NONE);
			tbtmNewItem_4.setText("会员照片");

			Composite composite_1 = new Composite(tabFolder, SWT.NONE);
			tbtmNewItem_4.setControl(composite_1);

			Label lblNewLabel_6 = new Label(composite_1, SWT.NONE);
			lblNewLabel_6.setBounds(10, 10, 54, 12);
			lblNewLabel_6.setText("New Label");
		}

		Label label = new Label(content, SWT.SEPARATOR | SWT.HORIZONTAL);
		label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1,
				1));

		Composite composite_1 = new Composite(content, SWT.NONE);
		composite_1.setLayout(new GridLayout(2, false));
		composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
				false, 1, 1));

		Button btnCheckButton = new Button(composite_1, SWT.CHECK);
		btnCheckButton.setText("保存后继续添加");

		Composite composite_2 = new Composite(composite_1, SWT.NONE);
		composite_2.setLayout(new RowLayout(SWT.HORIZONTAL));
		composite_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true,
				false, 1, 1));

		Button btnNewButton_1 = new Button(composite_2, SWT.NONE);
		btnNewButton_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (type == Edit)
					doEdit();
				else if (type == Add)
					doAdd();
			}
		});
		btnNewButton_1.setLayoutData(new RowData(80, SWT.DEFAULT));
		btnNewButton_1.setText("保存");

		Button btnNewButton = new Button(composite_2, SWT.NONE);
		btnNewButton.setLayoutData(new RowData(80, SWT.DEFAULT));
		btnNewButton.setBounds(0, 0, 72, 22);
		btnNewButton.setText("退出");
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				result = SWT.CANCEL;
				HyglEdit.this.content.dispose();
			}
		});
		if (type == Edit) {
			tbtmNewItem.dispose();
			tbtmNewItem_1.dispose();
		}
		setParams();
		createGUIAfter();
		setValues();
		this.content = content;
		return content;
	}

	protected void doAdd() {
		// 刷新参数
		setParams();
		// 新增护理计划
		String addSql = "insert into hyhljh(hybh,hlxmmc,hlnr) values(?,?,?)";
		for (TableItem itme : dataTableHljh.getItems()) {
			BatchItem additem = new BatchItem(hyxxAdd);
			additem.setCommand(addSql);
			additem.setParam(0, textHybh.getText());
			additem.setParam(1, itme.getText(0));
			additem.setParam(2, itme.getText(1));
		}
		hyxxAdd.execute();
		this.hybh = textHybh.getText();
		result = SWT.OK;
		content.dispose();
	}

	/**
	 * 修改会员信息
	 * */
	protected void doEdit() {
		setParams();
		// 新增护理计划
		String addSql = "insert into hyhljh(hybh,hlxmmc,hlnr) values(?,?,?)";
		for (TableItem itme : dataTableHljh.getItems()) {
			BatchItem additem = new BatchItem(hyxxEdit);
			additem.setCommand(addSql);
			additem.setParam(0, hyxxSet.getString("hybh"));
			additem.setParam(1, itme.getText(0));
			additem.setParam(2, itme.getText(1));
		}
		this.hybh = textHybh.getText();
		hyxxEdit.execute();
		result = SWT.OK;
		content.dispose();
	}

	protected void setParams() {
		hljhSet.setParam(0, hyxxSet.getValue("hybh"));
		hyxxEdit.setParam(0, 0, textHyxm.getText());
		hyxxEdit.setParam(0, 1, textXb.getText());
		hyxxEdit.setParam(0, 2, comboLb.getText());
		hyxxEdit.setParam(0, 3, combo_1.getText() + "-" + combo.getText());
		hyxxEdit.setParam(0, 4, text_2.getText());
		hyxxEdit.setParam(0, 5, button_6.getSelection());
		hyxxEdit.setParam(0, 6, dateTimeDqsj.getText());
		hyxxEdit.setParam(0, 7, textJj.getText());
		hyxxEdit.setParam(0, 8, textBz.getText());
		hyxxEdit.setParam(0, 9, text_8.getText());
		hyxxEdit.setParam(0, 10, dataCombo_2.getText());
		hyxxEdit.setParam(0, 11, ygSet.getValue("ygbh"));
		hyxxEdit.setParam(0, 12, hyxxSet.getValue("hybh"));
		hyxxEdit.setParam(1, 0, hyxxSet.getValue("hybh"));
		tcfwxmSet.setParam(0, tcSet.getValue("tcbh"));
		hyxxAdd.setParam(0, 0, textHybh.getText());
		hyxxAdd.setParam(0, 1, textHyxm.getText());
		hyxxAdd.setParam(0, 2, textXb.getText());
		hyxxAdd.setParam(0, 3, comboLb.getText());
		hyxxAdd.setParam(0, 4, combo_1.getText() + "-" + combo.getText());
		hyxxAdd.setParam(0, 5, text_2.getText());
		hyxxAdd.setParam(0, 6, button_6.getSelection());
		hyxxAdd.setParam(0, 7, dateTimeDqsj.getText());
		hyxxAdd.setParam(0, 8, textJj.getText());
		hyxxAdd.setParam(0, 9, textBz.getText());
		hyxxAdd.setParam(0, 10, text_8.getText());
		hyxxAdd.setParam(0, 11, dataCombo_2.getText());
		hyxxAdd.setParam(0, 12, ygSet.getValue("ygbh"));
		hyxxAdd.setParam(1, 0, textHybh.getText());
		hyxxAdd.setParam(2, 0, textHybh.getText());
		hyxxAdd.setParam(2, 1, tcSet.getValue("tcbh"));
	}

	protected void setValues() {
		textHybh.setText(hyxxSet.getValue("hybh", String.class, ""));
		textHyxm.setText(hyxxSet.getValue("hyxm", String.class, ""));
		textXb.setText(hyxxSet.getValue("xb", String.class, ""));
		comboLb.setText(hyxxSet.getValue("sr", String.class, ""));
		String csrq = hyxxSet.getValue("csrq", String.class, "");
		if (csrq.indexOf("-") != -1) {
			combo_1.setText(csrq.split("-")[0]);
			combo.setText(csrq.split("-")[1]);
		}
		text_2.setText(hyxxSet.getValue("lxdh", String.class, ""));
		button_6.setSelection(hyxxSet.getValue("Isqx", Boolean.class, false));
		textJj.setText(hyxxSet.getValue("mm", String.class, ""));
		textBz.setText(hyxxSet.getValue("bz", String.class, ""));
		textSj.setText(hyxxSet.getValue("mm", String.class, ""));
		String dqsj = hyxxSet.getValue("dqsj", String.class, "");
		try {
			if (dqsj != null && !dqsj.trim().equals("")) {
				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
				dateTimeDqsj.setSelection(format.parse(dqsj));
			} else {
				dateTimeDqsj.setSelection(null);
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		dateTimeDqsj.setEnabled(hyxxSet.getValue("Isqx", Boolean.class, false));
		hykSet.setSelected(hyxxSet.getValue("hykmc"));
		text_3.setText(hyxxSet.getValue("knje", String.class, ""));
		text_4.setText(hyxxSet.getValue("sj", String.class, ""));
		text_5.setText(hykSet.getValue("fwzk", String.class, ""));
		text_6.setText(hykSet.getValue("cpzk", String.class, ""));
		text_7.setText(hykSet.getValue("bz", String.class, ""));
		text_8.setText(hyxxSet.getValue("pfzk", String.class, ""));
		ygSet.setSelected(hyxxSet.getValue("ygbh"));
		if (type == Add) {
			newId.update();
			if (newId.getCount() > 0) {
				int newid = (Integer) newId.getValueForIndex(0, "newId");
				DecimalFormat format = new DecimalFormat("000000");
				textHybh.setText(format.format(newid));
			} else {
				textHybh.setText("000001");
			}
			textHybh.selectAll();
		}
	}

	protected void createGUIAfter() {
		tcSet.update();
		hykSet.update();
		ygSet.update();
		hljhSet.update();
		hlxmSet.update();

	}

}
